from page.base_page import BasePage
from appium.webdriver.common.appiumby import AppiumBy as By
class RepeatedSearchPage(BasePage):
    """搜索评论页面"""
    #定位器
    click_comment_locator=(By.ID,"com.xiachufang:id/recipe_bto_nav_bar_comment_btn")
    comment_locator=(By.ID,"com.xiachufang:id/eidt_comment_content")
    one_comment_name_locator=(By.XPATH,'//android.widget.TextView[@resource-id="com.xiachufang:id/tv_user_name" and @text="手机用户5831_43yn"]')
    add_comment_text_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("用户洒洒水5831_43yn")')
    unfavorite_locator=(By.ID,"com.xiachufang:id/recipe_bto_nav_bar_collect")
    send_locator=(By.XPATH,'//android.widget.TextView[@resource-id="com.xiachufang:id/tv_comment_publish_btn"]')
    def click_comment(self):
        """点击添加评论"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.click_comment_locator).click()
    def comment(self,content):
        """添加评论"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.comment_locator).send_keys(content)
    def click_send(self):
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.send_locator).click()
    def one_comment_name(self,content):
        """第一条评论用户名"""
        bp = BasePage(self.driver)
        return bp.show_waiting(self.driver, self.one_comment_name_locator).text
    def add_comment_text(self):
        """显示评论情况文本"""
        bp = BasePage(self.driver)
        return bp.show_waiting(self.driver, self.add_comment_text_locator).text
    def unfavorite(self):
        """点击收藏"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.unfavorite_locator).click()
    def return_key_code(self):
        """启动返回键"""
        self.driver.press_keycode(4)

